<template>
	<view>
		<navbox title="应用设置"></navbox>
		<view class="conn">
			<view style="margin-left: 10rpx;margin-right: 10rpx;background-color: #f9f9f9;border-radius: 10px;">
				<u-collapse @change="change" @close="close" @open="open" :value="['Docs','Docs-1']">
					<u-collapse-item title="系统信息" name="Docs-1">
						<view class="view1" style="height: 60rpx;" @click="show=true">
							<u-icon color="#ffecb9" slot="icon" size="32" name="calendar"></u-icon>
							<view class="view2" style="width: 150rpx;">消息状态:</view>
							<view style="width: 470rpx"></view>
							<view style="width: 30rpx;">{{setting.newsStatus==='0'?'拒收':'接收'}}</view>
							<u-icon color="#ffecb9" slot="icon" size="18" name="arrow-right"></u-icon>
						</view>
					</u-collapse-item>
					<u-collapse-item title="导航信息" name="Docs">
						<view class="view1">
							<u-icon :color="setting.navColor" slot="icon" size="32" name="calendar"></u-icon>
							<view class="view2" style="width: 150rpx;">导航背景色:</view>
							<u--input placeholder="请输入内容" v-model="setting.navColor" border="bottom" clearable>
							</u--input>
						</view>
						<view class="view1">
							<u-icon :color="setting.navFontColor" slot="icon" size="32" name="calendar"></u-icon>
							<view class="view2" style="width: 150rpx;">字体背景色:</view>
							<u--input placeholder="请输入内容" v-model="setting.navFontColor" border="bottom" clearable>
							</u--input>
						</view>
						<view class="view1">
							<u-icon :color="setting.status" slot="icon" size="32" name="calendar"></u-icon>
							<view class="view2" style="width: 150rpx;">菜单背景色:</view>
							<u--input placeholder="请输入内容" v-model="setting.status" border="bottom" clearable></u--input>
						</view>
					</u-collapse-item>
					<u-collapse-item title="背景设置" name="Docs guide">
						<view class="view1">
							<u-icon color="#ceacff" slot="icon" size="32" name="calendar"></u-icon>
							<view class="view2" style="width: 100%;">关于背景图</view>
						</view>
						<u--input placeholder="请输入内容" v-model="setting.memberBack" border="bottom" clearable>
						</u--input>
						<view class="view1">
							<u-icon color="#ceacff" slot="icon" size="32" name="calendar"></u-icon>
							<view class="view2" style="width: 100%;">个人中心背景图</view>
						</view>
						<u--input placeholder="请输入内容" v-model="setting.sideBack" border="bottom" clearable>
						</u--input>
						<view class="view1">
							<u-icon color="#ceacff" slot="icon" size="32" name="calendar"></u-icon>
							<view class="view2" style="width: 100%;">动态背景图</view>
						</view>
						<u--input placeholder="请输入内容" v-model="setting.frentBack" border="bottom" clearable>
						</u--input>
					</u-collapse-item>
				</u-collapse>
			</view>
		</view>
		<u-tabbar :value="value1" @change="change1" :fixed="true" :placeholder="false" :safeAreaInsetBottom="false">
			<u-tabbar-item text="首页" icon="home" @click="click1"></u-tabbar-item>
			<u-tabbar-item text="应用设置" icon="man-delete" @click="click1"></u-tabbar-item>
			<u-tabbar-item text="保存" icon="edit-pen" @click="click1"></u-tabbar-item>
		</u-tabbar>
		<u-picker :show="show" :columns="columns" @cancel="show=false" @confirm="confirm"></u-picker>

	</view>
</template>

<script>
	import navbox from '../components/navbox/navbox.vue'
	export default {
		data() {
			return {
				value1: 1,
				setting: {
				},
				show: false,
				columns: [
					['接受', '拒收']
				],
			}
		},
		methods: {
			async click1(e) {
			 
				if (e === 0) {
					uni.switchTab({
						url: '/pages/index/index'
					})
				} else if (e === 2) {
					this.setting.userId=uni.getStorageSync("user").id
					const res2 = await this.$myRuquest({
						url: '/wexinLogin/settingNews/settings',
						method: 'post',
						data: this.setting
					})
					uni.setStorageSync("settings", this.setting)
					uni.switchTab({
						url: '/pages/index/index'
					})
					uni.showToast({
						title: res2.data.data !== true ? "修改失败" : "修改成功,重新登录后生效",
						icon: 'none'
					})
				}
			},
			change1(name) {
				this.value1 = name
			},
			confirm(e) {
				console.log(e)
				if(e.value[0]==="接受"){
					this.setting.newsStatus="1"
				}else{
					this.setting.newsStatus="0"
				}
				console.log(this.setting.newsStatus)
				this.show=false
			},
			open(e) {
				// console.log('open', e)
			},
			close(e) {
				// console.log('close', e)
			},
			change(e) {
				// console.log('change', e)
			},
		},
		components: {
			"navbox": navbox
		},
		onLoad() {
			this.setting = uni.getStorageSync("settings")
		}
	}
</script>

<style lang="scss" scoped>
	.view1 {
		display: flex;
		align-items: center;
		justify-content: flex-start;
		height: 95rpx;
	}

	.view2 {
		margin-left: 10rpx;
		margin-left: 10rpx;
		width: 100rpx;
	}

	.conn {
		margin-top: 180rpx;
	}
</style>
